← Back to Home
🎯 Behavioral Pattern

Strategy Pattern

What is the Strategy Pattern?

The Strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. It lets the algorithm vary independently from clients that use it.

Key Concept: Instead of implementing a single algorithm directly, code receives runtime instructions on which algorithm to use from a family of algorithms.

💰 Discount Calculator

Select Discount Strategy:

🏷️
Regular Sale
20% off
Premium Member
30% off
👑
VIP Member
50% off